﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userinformation.aspx.cs" Inherits="user_userinformation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户详细信息</title>
    <script type="text/javascript" src="../js/jquery-1.6.1.js"></script>
    <script type="text/javascript">
     $(function(){
              function InfoSet()
             {
                $.ajax({
                        async:false,
                        url:'../API/A_Userinfomanage.aspx',
                        type:'POST',
                        data:{edit:'list'},
                        dataType:'json',
                        success:function(data)
                        {
                          $("#nickname").val(data.n);
                          $("span.nickname").text(data.n);
                          $("#sex").attr("value",data.s);
                          $("span.sex").text($("#sex").find("option:selected").text());
                          $("#qq").val(data.q);
                          $("span.qq").text(data.q);
                          $("#email").val(data.e);
                          $("span.email").text(data.e);
                          $("#tel").val(data.t);
                          $("span.tel").text(data.t);
                          $("#province").val(data.p);
                          $("span.province").text(data.p);
                          $("#city").val(data.c);
                          $("span.city").text(data.c);
                          $("#regtime").text(data.r);
                        }
                });
             }
             function InfoEdit()
             {
                var nickname=$("#nickname").val();
                var sex=$("#sex").find("option:selected").attr("value");
                var qq=$("#qq").val();
                var email=$("#email").val();
                var tel=$("#tel").val();
                var province=$("#province").val();
                var city=$("#city").val();
                $.ajax({
                        async:false,
                        url:'../API/A_Userinfomanage.aspx',
                        type:'POST',
                        data:{
                              edit:'set',
                              n:nickname,
                              s:sex,
                              q:qq,
                              e:email,
                              t:tel, 
                              p:province,
                              c:city
                        },
                        success:function(msg)
                        {
                          if(msg=="true"){
                          InfoSet();}
                          else{
                          alert(msg);}
                        }
                });
             }
            
             function UserOut()
             {
               $.ajax({
                      async:true,
                      url:'../API/A_Userinfomanage.aspx',
                      type:'POST',
                      data:{edit:'out'},
                      success:function(msg)
                      {
                         if(msg=='true')
                         {
                            window.location="../reg.aspx";
                         }
                      }
               });
             }
             function UpdateSet()
             {
               $("#infolist span").hide();
               $("#infolist input:text").show();
               $("#OK").show();
               $("#update").hide();
               $("#cancel").show();
               $("#sex").show();
             }
             function CancelSet()
             {
               $("#infolist input:text").hide();
               $("#infolist span").show();
               $("#OK").hide();
               $("#update").show();
               $("#cancel").hide();
               $("#sex").hide();
             }
             function UpdatePwd()
             {
                var oldpwd=$("#oldpwd").val();
                var okpwd=$("#okpwd").val();
                $.ajax({
                        async:false,
                        url:'../API/A_Userinfomanage.aspx',
                        type:'POST',
                        data:{
                              edit:'uppwd',
                              old:oldpwd,
                              ok:okpwd
                        },
                        dataType:'json',
                        success:function(data)
                        {
                          if(data.err=="1")
                          {
                            var flag=confirm("退出重新登录");
                            if(flag)
                            {
                              UserOut();
                            }
                          }
                          else
                          {
                            alert("旧密码错误");
                          }
                        }
                });
             }
             $("#OK").click(function(){
                         InfoEdit();
                         CancelSet();
             });
             $(document).ready(function(){
                         InfoSet();
                         CancelSet();
             });
             $("#out").click(function(){
                         UserOut();
             });
             $("#update").click(function(){
                         UpdateSet();
                         
             });
             $("#cancel").click(function(){
                         CancelSet();
             });
             $("#uppwd").click(function(){
                         UpdatePwd();
             });
     });
     javascript:window.history.forward(1);
    </script>
    <style type="text/css">
    .nickname{}
    .sex{}
    .qq{}
    .email{}
    .tel{}
    .province{}
    .city{}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table id="infolist">
      <tr>
        <td>用户昵称：</td>
        <td><span class="nickname"></span><input type="text" id="nickname" /></td>
      </tr>
      <tr>
        <td>性别：</td>
        <td><span class="sex"></span><select id="sex"><option value="1">男</option><option value="0">女</option></select></td>
      </tr>
      <tr>
        <td>QQ：</td>
        <td><span class="qq"></span><input type="text" id="qq" /></td>
      </tr>
      <tr>
        <td>Email：</td>
        <td><span class="email"></span><input type="text" id="email" /></td>
      </tr>
      <tr>
        <td>联系方式：</td>
        <td><span class="tel"></span><input type="text" id="tel" /></td>
      </tr>
      <tr>
        <td>省：</td>
        <td><span class="province"></span><input type="text" id="province" /></td>
      </tr>
      <tr>
        <td>市：</td>
        <td><span class="city"></span><input type="text" id="city" /></td>
      </tr>
      <tr>
        <td>注册时间：</td>
        <td><span id="regtime"></span></td>
      </tr>
      <tr>
        <td colspan="2"><input type="button" id="OK" value="保存" /><input type="button" id="update" value="修改" /><input type="button" id="cancel" value="取消" /><input type="button" id="out" value="退出" /></td>
      </tr>
    </table>
    </div>
    <div>
     <p>修改密码</p>
     旧密码：<input type="text" id="oldpwd" /><br />
     新密码：<input type="text" id="newpwd" /><br />
     确认密码：<input type="text" id="okpwd" /><br />
     <input id="uppwd" type="button" value="确认修改" />
    </div>
    <div><a href="../wallet/pay.aspx">账户充值</a></div>
    </form>
</body>
</html>
